package cn.com.chengmandian.bike.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration
public class CaffeineConfig {
    /**
     * 地区广告位缓存
     * @return
     */
    @Bean
    public Cache<String, Object> adListCaffeineCache() {
        return Caffeine.newBuilder()
                .maximumSize(10000)
                .expireAfterAccess(Duration.ofSeconds(60*60))
                .build();
    }

    /**
     * 价格缓存
     * @return
     */
    @Bean
    public Cache<String, Object> priceRuleCaffeineCache() {
        return Caffeine.newBuilder()
                .maximumSize(10000)
                .expireAfterAccess(Duration.ofSeconds(60*60))
                .build();
    }
}
